package pkg

import (
	"github.com/go-pay/gopay"
	"github.com/go-pay/gopay/alipay"
	"github.com/go-pay/xlog"
)

func AliYun() string {
	// 初始化支付宝客户端
	// appid：应用ID
	// privateKey：应用私钥，支持PKCS1和PKCS8
	// isProd：是否是正式环境，沙箱环境请选择新版沙箱应用。

	privateKey := "MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDBjKQgpqnvaLzqrDsmfSh0PseWkb4+q/PK8bHP53nUJzpJMdZhxv2qeYezdS6emT+2Tigu0dbjxyuh84yGpvDOKbHuzbeMd9zhKkIqBqVqYe01XCWUNZ5t9G7MwTHrhXBw2qT080Trlvl+WAacgOh9MEYQ/eFoEjJNf2QNVXzY/6ayIUte4ZSouwrfF5zhqExsbBClvQcuGcAtOhcfQ92+N2cMa5PspSRlDnr7DqkVS2g3edhV4YLSV2nYhk+WYQ/krm6qrTVKOEGuqNtDR0Rz59ZdHlkreem85gQOmoK+3rDXOLVW3BignxOUn+xW0xj9/Dp8LFpm5kbWz5b2iBNpAgMBAAECggEBAJ5wEqrnw5RHmN5Bvuny6nq+KYQIKkQDXr5yu6wFQKV6tyvTsDq6Okyiz4MIGfGaYZ1KvXoWLGKpV/5q8E4JunYJi66AmBBUzmtDvIXKiv5ay2My21BH1DkOLuVOAR9bTIAVe5NI0NJJ9FKInGDg5XAVZEXkjfAzdRobfjusD1dSAsQzu60NJbGxuk13VB+SIWJPLkF+HXeXQ6HOfs0AIN+E4yQnqw+d62pppodjJYEXV0NyBYBFGnSudsbEJMeyPLWAKlERCzQr+crF3TKTnxkH1pfcwi8PICkJ/fjUByqUZLD4a7qgWcUukFAg4fC1dhAYS2pFUlxlu0g3y5VhXQECgYEA6OlAwikhosoVMIanddWjTSAOweEDH+9QIqH9oRaD5WJRkdeK+PUqOTHeMRkNA6hXLA4v1zSdctYCm5fkkSNh4bpasS49hJZetZx1f/+mcp7VhyYZJZ/4leQCLX5zHi0AvDM2mPolZaMFB8jK/wHaE7B5+RLBW0SIQJdAp/yjUDUCgYEA1Lx6OmnauvrcnViVQDWZpS9FyhHbReQ25Pa55oS/I/TMZU+zaP/V83t3q8IL0MWcZKbDbw/11E9bZLZjFQynqal2yRXYOwXkK2FgcOg74Kj8F/B1FPLgT2FHNjcydqvY1/vmfO4GijGOVqAAXC8Ra5WqvgCCms2BG8njlkV+hOUCgYEA1qa5jvd3T18svicrSFbXBGpqD1Z/mbvlP7XJWN+2OP4urNlX8++GtWV3IAq1SsynYivE/XI5NS91Ac6v0O8p823azXYPLhWjPX7vb0K+NN6bbc232UwgPov/Ucw67fGNvuT4CW5obs4aAb2VEAW15PV8xAb7+lAjvltnNCqKnI0CgYEAi7uNMWcsQ9rZJAT2a+mJFUYauiLGe37uS7B/5RlWj2CRDQ6v0o0Q1FBKB6h6qFPUaQxcnEvIdf72Eg32wPHCAyALpQNTN1mkSJY6iY8RHX0BsRvBW9Q4YAuOgd75p5cy5JNSDsctxoHMc7u+4M4NzDPPpeOh5dqMLluKwL6+3r0CgYADhuyUuAyZ1MZvuSoIRimm5rceJTCx3LYnbCs5QmsWJDWLiIZxeFkDF11dX5Nnq/OazoY4cZLeRjk5w3bw/siHdfcnzT68yepNzOLiZehHrQQirkrEA9ObflXq+5bS7lwydd4hYx9EnRdxoIzhiq4i7nu+y7RW6NteJb29L6sfoQ=="
	client, err := alipay.NewClient("9021000139643438", privateKey, false)
	if err != nil {
		xlog.Error(err)

	}

	// 自定义配置http请求接收返回结果body大小，默认 10MB
	//client.SetBodySize() // 没有特殊需求，可忽略此配置

	// 设置自定义RequestId生成方法，非必须
	//client.SetRequestIdFunc()

	// 打开Debug开关，输出日志，默认关闭
	client.DebugSwitch = gopay.DebugOn

	// 设置支付宝请求 公共参数
	//    注意：具体设置哪些参数，根据不同的方法而不同，此处列举出所有设置参数
	client.SetLocation(alipay.LocationShanghai). // 设置时区，不设置或出错均为默认服务器时间
							SetCharset(alipay.UTF8).                                             // 设置字符编码，不设置默认 utf-8
							SetSignType(alipay.RSA2).                                            // 设置签名类型，不设置默认 RSA2
							SetReturnUrl("https://openapi-sandbox.dl.alipaydev.com/gateway.do"). // 设置返回URL
							SetNotifyUrl("https://www.baidu.com").                               // 设置异步通知URL
							SetAppAuthToken("https://www.daibu.com")                             // 设置第三方应用授权

	// 设置biz_content加密KEY，设置此参数默认开启加密（目前不可用，设置后会报错）
	//client.SetAESKey("1234567890123456")

	// 自动同步验签（只支持证书模式）
	// 传入 alipayPublicCert.crt 内容
	client.AutoVerifySign([]byte("alipayPublicCert.crt bytes"))

	// 公钥证书模式，需要传入证书，以下两种方式二选一
	// 证书路径
	err = client.SetCertSnByPath("appPublicCert.crt", "alipayRootCert.crt", "alipayPublicCert.crt")
	// 证书内容
	//err := client.SetCertSnByContent("appPublicCert.crt bytes", "alipayRootCert bytes", "alipayPublicCert.crt bytes")
	return ""
}
